#include "TextDrawer.h"


using namespace std;

void TextDrawer::renderBitmapString(float x, float y,float z, void *font,char *string)
{
	char *c;
	// set position to start drawing fonts
	glRasterPos3f(x, y,z);
	// loop all the characters in the string
	for (c=string; *c != '\0'; c++) {
		glutBitmapCharacter(font, *c);
	}
}

void TextDrawer::drawScore(int value,float x, float y,float z) 
{
	int font=(int)GLUT_BITMAP_HELVETICA_18;
	char buffer[100]; //Build FPS TEXT
	char text[25] = "Score: ";
	itoa(value,buffer,10);
	strcat_s(text,buffer);
	renderBitmapString(x,y,z,(void *)font,text);
}

void TextDrawer::drawNumOfCollisions(int value,float x, float y,float z) 
{
	int font=(int)GLUT_BITMAP_HELVETICA_18;
	char buffer[100]; //Build FPS TEXT
	char text[25] = "Collisions: ";
	itoa(value,buffer,10);
	strcat_s(text,buffer);
	renderBitmapString(x,y,z,(void *)font,text);
}

void TextDrawer::drawHighScoreNames(string value,float x, float y,float z) 
{
	int font=(int)GLUT_BITMAP_HELVETICA_18;
	char buffer[100]; //Build FPS TEXT
	
	char *a=new char[value.size()+1];
	a[value.size()]=0;
	memcpy(a,value.c_str(),value.size());

	//char text[25] = a;

	renderBitmapString(x,y,z,(void *)font,a);
}